package com.business.web.controller.system;

import java.util.List;

import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.business.common.annotation.Log;
import com.business.common.core.controller.BaseController;
import com.business.common.core.domain.AjaxResult;
import com.business.common.enums.BusinessType;
import com.business.system.domain.Movie;
import com.business.system.service.IMovieService;
import com.business.common.core.page.TableDataInfo;

/**
 * 电影Controller
 * 
 * @author ruoyi
 * @date 2025-06-14
 */
@RestController
@RequestMapping("/system/movie")
public class MovieController extends BaseController
{
    @Autowired
    private IMovieService movieService;

    /**
     * 查询电影列表
     */
    @PreAuthorize("@ss.hasPermi('system:movie:list')")
    @GetMapping("/list")
    public TableDataInfo list(Movie movie)
    {
        startPage();
        List<Movie> list = movieService.selectMovieList(movie);
        return getDataTable(list);
    }


    /**
     * 获取电影详细信息
     */
    @PreAuthorize("@ss.hasPermi('system:movie:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(movieService.selectMovieById(id));
    }

    /**
     * 新增电影
     */
    @PreAuthorize("@ss.hasPermi('system:movie:add')")
    @PostMapping
    public AjaxResult add(@RequestBody Movie movie)
    {
        return toAjax(movieService.insertMovie(movie));
    }

    /**
     * 修改电影
     */
    @PreAuthorize("@ss.hasPermi('system:movie:edit')")
    @PutMapping
    public AjaxResult edit(@RequestBody Movie movie)
    {
        return toAjax(movieService.updateMovie(movie));
    }

    /**
     * 删除电影
     */
    @PreAuthorize("@ss.hasPermi('system:movie:remove')")
    @DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(movieService.deleteMovieByIds(ids));
    }
}
